package com.wtwd.campus.adapter;

import com.wtwd.campus.common.RespCode;
import com.wtwd.campus.entity.VerifyResult;
import com.wtwd.campus.service.RedisService;
import org.apache.commons.lang.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author mjy
 * @Date create in 16:07 2022/2/14
 * @Description
 */
public class JdzcAdapter extends VerifyAdapter{

    public JdzcAdapter(HttpServletRequest request) {
        super(request);
        encryptVerify = null;
    }


    @Override
    public VerifyResult verifyEncrypt(HttpServletRequest request, RedisService redisService) {
        if(encryptVerify == null){
            VerifyResult verifyResult = new VerifyResult();
            if (StringUtils.isBlank(JdzcToken)) {
                verifyResult.setResult(false);
                verifyResult.setRespCode(RespCode.USER_INDEX_EXPIRE);
                return verifyResult;
            }
            // 获取token对应的东西
            if (!redisService.hasKey(JdzcToken)) {
                verifyResult.setResult(false);
                verifyResult.setRespCode(RespCode.USER_INDEX_EXPIRE);
                return verifyResult;
            }
        }
        return null;
    }
}
